﻿namespace MDXStudio.Tracing
{
    using Microsoft.AnalysisServices;
    using System;
    using System.Collections.Generic;
    using System.Reflection;

    internal class TracerSetting
    {
        private List<TraceEventClass> mEventTypeList = new List<TraceEventClass>();
        private List<string> mPropertyList = new List<string>();
        private static TracerSetting sDefaultSetting;
        private static TracerSetting sFullSetting;

        public TracerSetting GetDeepCopy()
        {
            TracerSetting setting = new TracerSetting();
            setting.mPropertyList.AddRange(this.mPropertyList);
            setting.mEventTypeList.AddRange(this.mEventTypeList);
            return setting;
        }

        public static TracerSetting GetDefaultSetting()
        {
            if (sDefaultSetting == null)
            {
                sDefaultSetting = new TracerSetting();
                sDefaultSetting.mEventTypeList.Add(9);
                sDefaultSetting.mEventTypeList.Add(10);
                sDefaultSetting.mEventTypeList.Add(12);
                sDefaultSetting.mEventTypeList.Add(0x51);
                sDefaultSetting.mEventTypeList.Add(0x48);
                sDefaultSetting.mEventTypeList.Add(0x4a);
                sDefaultSetting.mEventTypeList.Add(40);
                sDefaultSetting.mPropertyList.Add("EventClass");
                sDefaultSetting.mPropertyList.Add("EventSubclass");
                sDefaultSetting.mPropertyList.Add("TextData                                                              ");
                sDefaultSetting.mPropertyList.Add("Duration");
                sDefaultSetting.mPropertyList.Add("CpuTime");
                sDefaultSetting.mPropertyList.Add("EndTime");
                sDefaultSetting.mPropertyList.Add("ObjectName");
                sDefaultSetting.mPropertyList.Add("ObjectPath           ");
                sDefaultSetting.mPropertyList.Add("ObjectReference");
            }
            return sDefaultSetting;
        }

        public static TracerSetting GetFullSetting()
        {
            if (sFullSetting == null)
            {
                sFullSetting = new TracerSetting();
                foreach (object obj2 in Enum.GetValues(typeof(TraceEventClass)))
                {
                    sFullSetting.mEventTypeList.Add((TraceEventClass) obj2);
                }
                Type type = typeof(TracerEvent);
                foreach (PropertyInfo info in type.GetProperties())
                {
                    sFullSetting.mPropertyList.Add(info.Name);
                }
            }
            return sFullSetting;
        }

        public List<TraceEventClass> EventTypeList
        {
            get
            {
                return this.mEventTypeList;
            }
        }

        public List<string> PropertyList
        {
            get
            {
                return this.mPropertyList;
            }
        }
    }
}

